<?php
  $total_records = 18;
  $cols = 4;
  $rows = ceil($total_records / $cols);
  $count = 1;
?>
<table  border="1" width="80%" align="center">
<?php
  for ($i = 1; $i <= $rows; $i++) {
    $color = ($i%2==0)?'yellow':'pink';
?>
    <tr style="background:<?=$color?>">
      <?php for($j=1 ; $j<= $cols ; $j++) {
if($count <= $total_records) {
      ?>
      <td align="center">ITEM-<?=$count++?></td>
      <?php
} else {//end if()
?>
      <td align="center">&nbsp;</td>
<?php
}
      }//end for()?>

    </tr>
<?php
  }
?>
</table>
